package model

import (
	"strings"
)

type FabricChain struct {
	ChainName       string   `json:"chain_name"`
	OrdererName     string   `json:"orderer"`
	PeersOrgs       []string `json:"peers_orgs"`   //参与组织 除了orderer
	ChannelName     string   `json:"channel_name"` //channel 名
	WorkPath	    string   `json:"work_path"`
	ChannelPath	    string   `json:"channel_path"`
	CryptoPath	    string   `json:"crypto_path"`
	ChaincodeSourcePath	string    `json:"chaincode_source_path"`
}

func (f FabricChain) GetHostDomain(org string) string {
	return strings.ToLower(f.ChainName + org)
}

type FabricChannel struct {
	FabricChain
	ChaincodeName  string   `json:"chaincode_name"`
	GithubPath     string   `json:"github_path"`
	Version        string   `json:"version"`
	Policy         string   `json:"policy"`
	ArgsGm         [][]byte `json:"args_gm"`
}


type FabricChannelAndChaincodeWithOrg struct {
	FabricChannelWithOrg
	ChaincodeName  string   `json:"chaincode_name"`
	GithubPath     string   `json:"github_path"`
	Version        string   `json:"version"`
	Language       string   `json:"language"`
	Policy         string   `json:"policy"`
	ArgsGm         [][]byte `json:"args_gm"`
}

type FabricChannelWithOrg struct {
	ChainName       string   `json:"chain_name"`
	OrdererName     string   `json:"orderer"`
	PeersOrgs       []string `json:"peers_orgs"`      //参与组织
	OrgPeers        []string `json:"org_peers"`       //参与节点
	EndorserOrgs    []string `json:"endorser_orgs"`   //背书组织
	ApprovePeers    []string `json:"approve_peers"`
	EndorserPeers   []string `json:"endorser_peers"`  //背书节点
	ChannelName     string   `json:"channel_name"`    //channel 名
	WorkPath	    string   `json:"work_path"`
	ChannelPath	    string   `json:"channel_path"`
	CryptoPath	    string    `json:"crypto_path"`
	ChaincodeSourcePath	string    `json:"chaincode_source_path"`
}

func (f FabricChannel) GetChain() FabricChain {
	return f.FabricChain
}
